home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 24
/
Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso
/
Aminet
/
dev
/
lang
/
PPCcforth.lha
/
PPCcforth
/
lex.yy.c
< prev
next >
Wrap
C/C++ Source or Header
|
1985-12-27
|
16KB
|
910 lines
# include "stdio.h"
# define U(x) x
# define NLSTATE yyprevious=YYNEWLINE
# define BEGIN yybgin = yysvec + 1 +
# define INITIAL 0
# define YYLERR yysvec
# define YYSTATE (yyestate-yysvec-1)
# define YYOPTIM 1
# define YYLMAX 200
# define output(c) putc(c,yyout)
# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
# define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;}
# define yymore() (yymorfg=1)
# define ECHO fprintf(yyout, "%s",yytext)
# define REJECT { nstr = yyreject(); goto yyfussy;}
int yyleng; extern char yytext[];
int yymorfg;
extern char *yysptr, yysbuf[];
int yytchar;
FILE *yyin = {stdin}, *yyout = {stdout};
extern int yylineno;
struct yysvf {
struct yywork *yystoff;
struct yysvf *yyother;
int *yystops;};
struct yysvf *yyestate;
extern struct yysvf yysvec[], *yybgin;
/* LEX input for FORTH input file scanner */
/*
Specifications are as follows:
This file must be run through "sed" to change
yylex () {
to
TOKEN *yylex () {
where the sed script is
sed "s/yylex () {/TOKEN *yylex () {/" lex.yy.c
Note that spaces have been included above so these lines won't be
mangled by sed; in actuality, the two blanks surrounding () are
removed.
The function "yylex()" always returns a pointer to a structure:
struct tokenrec {
int type;
char *text;
}
#define TOKEN struct tokenrec
where the type is a hint as to the word's type:
DECIMAL for decimal literal d+
OCTAL for octal literal 0d*
HEX for hex literal 0xd+ or 0Xd+
C_BS for a literal Backspace '\b'
C_FF for a literal Form Feed '\f'
C_NL for a literal Newline '\n'
C_CR for a literal Carriage Return '\r'
C_TAB for a literal Tab '\t'
C_BSLASH for a literal backslash '\\'
C_IT for an other character literal 'x' where x is possibly '
STRING_LIT for a string literal (possibly containing \")
COMMENT for a left-parenthesis (possibly beginning a comment)
PRIM for "PRIM"
CONST for "CONST"
VAR for "VAR"
USER for "USER"
LABEL for "LABEL"
COLON for ":"
SEMICOLON for ";"
SEMISTAR for ";*" (used to make words IMMEDIATE)
NUL for the token {NUL}, which gets compiled as a null byte;
this special interpretation takes place in the COLON
code.
LIT for the word "LIT" (treated like OTHER, except that
no warning is generated when a literal follows this)
OTHER for an other word not recognized above
Note that this is just a hint: the meaning of any string of characters
depends on the context.
*/
#include "forth.lex.h"
TOKEN token;
# define YYNEWLINE 10
TOKEN *yylex(){
int nstr; extern int yyprevious;
while((nstr = yylook()) >= 0)
yyfussy: switch(nstr){
case 0:
if(yywrap()) return(0); break;
case 1:
/* whitespace -- keep looping */ ;
break;
case 2:
{ token.type = DECIMAL; token.text = yytext;
return &token; }
break;
case 3:
{ token.type = OCTAL; token.text = yytext;
return &token; }
break;
case 4:
{ token.type = HEX; token.text = yytext;
return &token; }
break;
case 5:
{ token.type = C_BS; token.text = yytext; return &token; }
break;
case 6:
{ token.type = C_FF; token.text = yytext; return &token; }
break;
case 7:
{ token.type = C_NL; token.text = yytext; return &token; }
break;
case 8:
{ token.type = C_CR; token.text = yytext; return &token; }
break;
case 9:
{ token.type = C_TAB; token.text = yytext; return &token; }
break;
case 10:
{ token.type = C_BSLASH; token.text = yytext; return &token; }
break;
case 11:
{ token.type = C_LIT; token.text = yytext; return &token; }
break;
case 12:
{ token.type = STRING_LIT; token.text = yytext;
return &token; }
break;
case 13:
{ token.type = COMMENT; token.text = yytext;
return &token; }
break;
case 14:
{ token.type = PRIM; token.text = yytext;
return &token; }
break;
case 15:
{ token.type = CONST; token.text = yytext;
return &token; }
break;
case 16:
{ token.type = VAR; token.text = yytext;
return &token; }
break;
case 17:
{ token.type = USER; token.text = yytext;
return &token; }
break;
case 18:
{ token.type = LABEL; token.text = yytext;
return &token; }
break;
case 19:
{ token.type = COLON; token.text = yytext;
return &token; }
break;
case 20:
{ token.type = SEMICOLON; token.text = yytext;
return &token; }
break;
case 21:
{ token.type = SEMISTAR; token.text = yytext;
return &token; }
break;
case 22:
{ token.type = NUL; token.text = yytext;
return &token; }
break;
case 23:
{ token.type = LIT; token.text = yytext;
return &token; }
break;
case 24:
{ token.type = OTHER; token.text = yytext;
return &token; }
break;
case -1:
break;
default:
fprintf(yyout,"bad switch yylook %d",nstr);
} return(0); }
/* end of yylex */
int yyvstop[] = {
0,
1,
0,
1,
0,
-24,
0,
1,
0,
-24,
0,
-24,
0,
-13,
-24,
0,
-24,
0,
-3,
-24,
0,
-2,
-24,
0,
-19,
-24,
0,
-20,
-24,
0,
-24,
0,
-24,
0,
-24,
0,
-24,
0,
-24,
0,
-24,
0,
24,
0,
24,
0,
-12,
-24,
0,
-24,
0,
-24,
0,
24,
0,
-24,
0,
13,
24,
0,
3,
24,
0,
-3,
-24,
0,
-24,
0,
2,
24,
0,
19,
24,
0,
20,
24,
0,
-21,
-24,
0,
-24,
0,
-24,
0,
-24,
0,
-24,
0,
-24,
0,
-24,
0,
-24,
0,
-12,
0,
12,
24,
0,
-12,
-24,
0,
-11,
-24,
0,
-11,
0,
-24,
0,
-24,
0,
-24,
0,
-24,
0,
-24,
0,
-24,
0,
-4,
-24,
0,
21,
24,
0,
-24,
0,
-24,
0,
-23,
-24,
0,
-24,
0,
-24,
0,
-16,
-24,
0,
-24,
0,
12,
0,
-12,
0,
12,
24,
0,
11,
24,
0,
11,
0,
-10,
-24,
0,
-5,
-24,
0,
-6,
-24,
0,
-7,
-24,
0,
-8,
-24,
0,
-9,
-24,
0,
4,
24,
0,
-24,
0,
-24,
0,
23,
24,
0,
-14,
-24,
0,
-17,
-24,
0,
16,
24,
0,
-24,
0,
12,
0,
10,
24,
0,
5,
24,
0,
6,
24,
0,
7,
24,
0,
8,
24,
0,
9,
24,
0,
-15,
-24,
0,
-18,
-24,
0,
14,
24,
0,
17,
24,
0,
-22,
-24,
0,
15,
24,
0,
18,
24,
0,
22,
24,
0,
0};
# define YYTYPE char
struct yywork { YYTYPE verify, advance; } yycrank[] = {
0,0, 0,0, 1,3, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 1,4, 1,4,
0,0, 4,4, 4,4, 0,0,
4,4, 4,4, 7,26, 7,26,
11,31, 11,31, 21,44, 21,44,
0,0, 12,32, 12,32, 33,55,
33,55, 0,0, 42,63, 42,63,
0,0, 42,63, 42,63, 1,5,
4,4, 46,66, 46,66, 0,0,
1,6, 1,7, 22,45, 3,3,
23,46, 24,47, 1,8, 48,68,
49,69, 1,9, 1,10, 3,19,
3,19, 42,63, 50,70, 2,6,
2,7, 1,10, 12,33, 1,11,
1,12, 2,8, 5,5, 51,71,
6,23, 52,72, 1,3, 43,64,
1,13, 35,57, 5,20, 5,20,
6,24, 6,19, 2,11, 2,12,
3,3, 1,14, 37,59, 38,60,
18,40, 1,15, 13,34, 2,13,
15,37, 16,38, 1,16, 1,17,
34,56, 1,3, 3,3, 3,3,
2,14, 9,27, 9,27, 5,21,
2,15, 6,23, 3,3, 36,58,
22,22, 2,16, 2,17, 10,30,
10,30, 8,9, 8,10, 3,3,
39,61, 5,5, 5,5, 6,23,
6,23, 8,10, 14,3, 40,62,
41,43, 5,5, 53,73, 6,23,
28,27, 28,27, 14,19, 14,19,
1,18, 43,43, 5,5, 56,75,
6,23, 57,76, 3,3, 59,78,
9,28, 9,28, 45,65, 45,65,
58,77, 58,77, 60,79, 2,18,
29,54, 29,54, 10,10, 10,10,
62,81, 25,46, 65,43, 14,3,
29,54, 5,5, 10,10, 6,23,
75,89, 5,22, 76,90, 6,25,
81,93, 29,54, 82,43, 28,28,
28,28, 14,3, 14,3, 0,0,
47,67, 47,67, 0,0, 47,67,
47,67, 14,3, 61,80, 61,80,
9,29, 64,82, 64,82, 0,0,
17,3, 0,0, 14,35, 14,3,
14,3, 14,3, 14,3, 14,3,
17,19, 17,19, 14,36, 47,67,
68,83, 68,83, 69,84, 69,84,
70,85, 70,85, 71,86, 71,86,
72,87, 72,87, 25,48, 73,88,
73,88, 14,3, 78,91, 78,91,
25,49, 79,92, 79,92, 0,0,
25,50, 17,3, 14,3, 14,3,
14,3, 14,3, 14,3, 14,3,
25,51, 45,22, 89,94, 89,94,
25,52, 0,0, 25,53, 17,3,
17,3, 90,95, 90,95, 93,96,
93,96, 0,0, 0,0, 17,3,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 20,41, 0,0,
17,39, 17,3, 17,3, 17,3,
17,3, 17,3, 20,41, 20,41,
54,74, 54,74, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0,
64,43, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 17,3,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 20,42,
17,3, 17,3, 17,3, 17,3,
17,3, 17,3, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 20,41, 20,41, 54,54,
54,54, 0,0, 0,0, 0,0,
0,0, 20,41, 0,0, 54,54,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 20,41, 0,0,
54,54, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 20,41, 0,0, 0,0,
0,0, 20,43, 0,0, 0,0,
0,0};
struct yysvf yysvec[] = {
0, 0, 0,
yycrank+-1, 0, yyvstop+1,
yycrank+-16, yysvec+1, yyvstop+3,
yycrank+-42, 0, yyvstop+5,
yycrank+4, 0, yyvstop+7,
yycrank+-61, 0, yyvstop+9,
yycrank+-63, 0, yyvstop+11,
yycrank+-9, yysvec+3, yyvstop+13,
yycrank+-57, yysvec+3, yyvsto